/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service.impl;

import org.springblade.modules.admin.dto.MaintainPartsAttributePageDTO;
import org.springblade.modules.admin.entity.MaintainPartsAttribute;
import org.springblade.modules.admin.enums.MaintainPartsAttributeNatureEnum;
import org.springblade.modules.admin.vo.MaintainPartsAttributePageVO;
import org.springblade.modules.admin.mapper.MaintainPartsAttributeMapper;
import org.springblade.modules.admin.service.IMaintainPartsAttributeService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.admin.vo.MaintainPartsAttributeSelectVO;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;

/**
 * 配件_属性表 服务实现类
 *
 * @author ysq
 * @since 2024-10-10
 */
@Service
public class MaintainPartsAttributeServiceImpl extends BaseServiceImpl<MaintainPartsAttributeMapper, MaintainPartsAttribute> implements IMaintainPartsAttributeService {

	@Override
	public IPage<MaintainPartsAttributePageVO> selectPageByCondition(IPage<MaintainPartsAttributePageVO> page, MaintainPartsAttributePageDTO pageDTO) {
		IPage<MaintainPartsAttributePageVO> result = baseMapper.selectPageByCondition(page, pageDTO);
		List<MaintainPartsAttributePageVO> records = result.getRecords();
		records.forEach(f -> {
			Integer nature = f.getNature();
			f.setNatureName(MaintainPartsAttributeNatureEnum.getName(nature));
		});
		result.setRecords(records);
		return result;
	}

	@Override
	public List<MaintainPartsAttributeSelectVO> selectList() {
		return baseMapper.selectListVO();
	}
}
